home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / network / nsclilib / ni_msg.h < prev    next >
Text File  |  1996-07-05  |  11KB  |  336 lines

  1. /*
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE
  5. *               National Center for Biotechnology Information
  6. *
  7. *  This software/database is a "United States Government Work" under the
  8. *  terms of the United States Copyright Act.  It was written as part of
  9. *  the author's official duties as a United States Government employee and
  10. *  thus cannot be copyrighted.  This software/database is freely available
  11. *  to the public for use. The National Library of Medicine and the U.S.
  12. *  Government have not placed any restriction on its use or reproduction.
  13. *
  14. *  Although all reasonable efforts have been taken to ensure the accuracy
  15. *  and reliability of the software and data, the NLM and the U.S.
  16. *  Government do not and cannot warrant the performance or results that
  17. *  may be obtained by using this software or data. The NLM and the U.S.
  18. *  Government disclaim all warranties, express or implied, including
  19. *  warranties of performance, merchantability or fitness for any particular
  20. *  purpose.
  21. *
  22. *  Please cite the author in any work or product based on this material.
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:    ni_msg.h
  27. *
  28. * Author:       Beatty, Gish
  29. *
  30. * Version Creation Date:        1/1/92
  31. *
  32. * $Revision: 4.0 $
  33. *
  34. * File Description:
  35. *
  36. *
  37. * Modifications:
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. * 5/12/92  Epstein     Converted tabs to spaces
  42. *
  43. * 04-21-93 Schuler     Changed declaration of NI_AsnNew(), NI_AsnWrite(), 
  44. *                      and NI_ASNIOError() to use LIBCALLBACK calling convention.
  45. *
  46. *
  47. * ==========================================================================
  48. *
  49. *
  50. * RCS Modification History:
  51. * $Log: ni_msg.h,v $
  52.  * Revision 4.0  1995/07/26  13:56:32  ostell
  53.  * force revision to 4.0
  54.  *
  55.  * Revision 1.17  1995/05/24  12:08:49  epstein
  56.  * add support for tracking of how many times a client IP has used a service within a time interval
  57.  *
  58.  * Revision 1.16  95/05/17  17:52:44  epstein
  59.  * add RCS log revision history
  60.  * 
  61. */
  62.  
  63. #ifndef _NI_MSG_
  64. #define _NI_MSG_
  65.  
  66. #include <setjmp.h>
  67.  
  68. #include "ncbinet.h"
  69. #include "ni_net.h"
  70.  
  71. #include "ni_list.h"
  72.  
  73.  
  74. #ifdef WIN16
  75. #define Jumpbuf   CATCHBUF
  76. #define SetJump   Catch
  77. #define LongJump  Throw
  78. #else
  79. #define Jumpbuf   jmp_buf
  80. #define SetJump   setjmp
  81. #define LongJump  longjmp
  82. #endif
  83.  
  84. #define NI_BLOCK_TIMEOUT        60
  85. #define NI_BLOCKSIZE            4096 /* matches TCP_MAXSEG in many systems */
  86.  
  87. /* VARS */
  88.  
  89. extern Uint4    conid;          /* globally unique connection ID counter */
  90.  
  91.  
  92. /* TYPES */
  93.  
  94. #define MsgType enum msgtype
  95. MsgType {
  96.         NI_UNKNOWN = 0,
  97.         NI_ACK,
  98.         NI_NACK,
  99.         NI_LOGIN,
  100.         NI_SVC_LIST,
  101.         NI_SVC_REQUEST,
  102.         NI_SVC_RESPONSE,
  103.         NI_COMMAND,
  104.         NI_ACCT,
  105.         NI_CATALOG,
  106.         NI_SVC_PRE_RESPONSE
  107. };
  108.  
  109. #define MsgCommand enum msgcommand
  110. MsgCommand {
  111.         NI_SEND_SVCLIST = 1,    /* send me a list of your services */
  112.         NI_SEND_CATALOG,        /* send me the catalog (dispatcher) */
  113.         NI_KILL,                /* kill yourself */
  114.         NI_POLL                 /* health check poll */
  115. };
  116.  
  117. typedef struct NIPubKey { /* internal format for public key */
  118.         Int2            bits;           /* bits used in modulus */
  119.         ByteStorePtr    modulus;
  120.         ByteStorePtr    exponent;
  121. } NIPubKey, PNTR NIPubKeyPtr;
  122.  
  123. typedef struct NIDispInfo {
  124.         Int4            serialno;       /* unique dispatcher serial # */
  125.         Boolean         isalternatelist;/* is this an alternate disp-list ? */
  126.         int             numdispatchers; /* number of dispatchers in disp-list */
  127.         CharPtr PNTR    displist;       /* list of dispatchers */
  128.         NIPubKeyPtr     pubKey;         /* public RSA key */
  129. } NIDispInfo, PNTR NIDispInfoPtr;
  130.  
  131. typedef struct NIAck {
  132.         Uint4           seqno;
  133.         NIDispInfoPtr   dispinfo;
  134.         CharPtr         adminInfo;      /* info. regarding guest's admin */
  135.         CharPtr         motd;           /* message of the day */
  136. } NIAck, PNTR NIAckPtr;
  137.  
  138. typedef struct NINack {
  139.         Uint4           seqno;
  140.         NI_Error        code;
  141.         CharPtr         reason;
  142.         NIDispInfoPtr   dispinfo;
  143. } NINack, PNTR NINackPtr;
  144.  
  145. typedef struct NILogin {
  146.         Uint4           seqno;
  147.         NI_UidPtr       uid;            /* ID structure */
  148.         CharPtr         password;       /* must be encrypted */
  149.         Int4            dispserialno;   /* unique dispatcher serial # */
  150.         Boolean         encryptionDesired; /* encryption desired by client */
  151.         NIPubKeyPtr     pubKey;         /* public RSA key */
  152.         ByteStorePtr    desKey;         /* DES key for ncbid<->dispd comm */
  153.         Int2            connectDelay;   /* connection delay (seconds) */
  154. } NILogin, PNTR NILoginPtr;
  155.  
  156. typedef struct NISvcList {
  157.         Uint4           seqno;
  158.         NIToolsetPtr    toolset;
  159.         Boolean         knowsTracking;  /* does this ncbid know about tracking? */
  160. } NISvcList, PNTR NISvcListPtr;
  161.  
  162. typedef struct NISvcReq {
  163.         Uint4           seqno;
  164.         Uint4           conid;          /* for client accounting */
  165.         NI_UidPtr       uid;
  166.         ReqPtr          request;
  167.         Uint4           platform;       /* client's platform */
  168.         CharPtr         applId;         /* application identifier */
  169.         ByteStorePtr    desKey;
  170.         Boolean         wantPreResponse; /* client wants to know server's IP */
  171.         Uint4           server_ip;
  172. } NISvcReq, PNTR NISvcReqPtr;
  173.  
  174. typedef struct NISvcResp {
  175.         Uint4           seqno;
  176.         ReqPtr          request;
  177. } NISvcResp, PNTR NISvcRespPtr;
  178.  
  179. typedef struct NICmd {
  180.         Uint4           seqno;
  181.         MsgCommand      code;
  182. } NICmd, PNTR NICmdPtr;
  183.  
  184. typedef struct NIPreResp {
  185.         Uint4           seqno;
  186.         Uint4           server_ip;
  187. } NIPreResp, PNTR NIPreRespPtr;
  188.  
  189. typedef struct NIAcct {
  190.         Uint4           seqno;
  191.         Uint4           conid;
  192.         CharPtr         jobname;
  193.         Uint4           usertime;
  194.         Uint4           systemtime;
  195. } NIAcct, PNTR NIAcctPtr;
  196.  
  197. typedef union NIMSun {
  198.         NIAckPtr        ack;
  199.         NINackPtr       nack;
  200.         NILoginPtr      login;
  201.         NISvcListPtr    svclist;
  202.         NISvcReqPtr     svcreq;
  203.         NISvcRespPtr    svcresp;
  204.         NICmdPtr        command;
  205.         NIAcctPtr       acct;
  206.         NICatalogPtr    catalog;
  207.         NIPreRespPtr    preresp;
  208. } NIMSun, PNTR NIMSunPtr;
  209.  
  210. typedef struct NIMessage {
  211.         MsgType         type;
  212.         Uint4           conid;          /* for ACKing */
  213.         NIMSun          msun;           /* message structure union */
  214. } NIMessage, PNTR NIMsgPtr;
  215.  
  216.  
  217. /* FUNCTION PROTOTYPES */
  218.  
  219. extern NIMsgPtr         MsgRead PROTO((MHandPtr handle, Boolean unblocked));
  220.  
  221. extern Int2             MsgWrite PROTO((MHandPtr handle, NIMsgPtr mp, Boolean noDestroy));
  222.  
  223. extern NIMsgPtr         MsgBuild PROTO((MsgType type, Uint4 conn, VoidPtr stp));
  224.  
  225. extern Int2             MsgDestroy PROTO((NIMsgPtr mp));
  226.  
  227. extern MHandPtr         MsgMakeHandle PROTO((Boolean createSocket));
  228.  
  229. extern Int2             MsgDestroyHandle PROTO((MHandPtr hp));
  230.  
  231. extern void             MsgSetLJError PROTO((MHandPtr mh));
  232.  
  233. extern void             MsgSetReadTimeout PROTO((MHandPtr mh, int t));
  234.  
  235. extern void             MsgSetWriteTimeout PROTO((MHandPtr mh, int t));
  236.  
  237. extern void             MsgSetFilters PROTO((MHandPtr mh, VoidPtr ex_proc, NI_WriteFilt wfilt, NI_ReadFilt rfilt, Boolean wfilt_pass, Boolean rfilt_pass));
  238.  
  239. extern void             MsgSetTimeoutHooks PROTO((MHandPtr mh, NI_TimeoutHook rhook, NI_TimeoutHook whook));
  240.  
  241. extern Int2 LIBCALLBACK NI_AsnRead PROTO((Pointer p, CharPtr buf, Uint2 len));
  242.  
  243. extern Int2 LIBCALLBACK NI_AsnWrite PROTO((Pointer p, CharPtr buf, Uint2 len));
  244.  
  245. extern void LIBCALLBACK NI_ASNIOError PROTO((Int2 level, CharPtr str));
  246.  
  247. extern int              NI_poll_select PROTO((int width, fd_set PNTR rfds, fd_set PNTR wfds, fd_set PNTR xfds, struct timeval PNTR timeout));
  248. extern int              NI_SetBlocking PROTO((int sock));
  249. extern int              NI_SetNonBlocking PROTO((int sock));
  250.  
  251.  
  252. /* Message Type Functions */
  253.  
  254. extern NIAckPtr         NI_MakeMsgAck PROTO((void));
  255.  
  256. extern Int2             NI_DestroyMsgAck PROTO((NIAckPtr));
  257.  
  258. extern NINackPtr        NI_MakeMsgNack PROTO((void));
  259.  
  260. extern Int2             NI_DestroyMsgNack PROTO((NINackPtr));
  261.  
  262. extern NILoginPtr       NI_MakeMsgLogin PROTO((void));
  263.  
  264. extern Int2             NI_DestroyMsgLogin PROTO((NILoginPtr));
  265.  
  266. extern NISvcListPtr     NI_MakeMsgSvclist PROTO((void));
  267.  
  268. extern Int2             NI_DestroyMsgSvclist PROTO((NISvcListPtr));
  269.  
  270. extern NISvcReqPtr      NI_MakeMsgSvcreq PROTO((void));
  271.  
  272. extern Int2             NI_DestroyMsgSvcreq PROTO((NISvcReqPtr));
  273.  
  274. extern NISvcRespPtr     NI_MakeMsgSvcresp PROTO((void));
  275.  
  276. extern Int2             NI_DestroyMsgSvcresp PROTO((NISvcRespPtr));
  277.  
  278. extern NICmdPtr         NI_MakeMsgCmd PROTO((void));
  279.  
  280. extern Int2             NI_DestroyMsgCmd PROTO((NICmdPtr));
  281.  
  282. extern NIPreRespPtr     NI_MakeMsgPreResp PROTO((void));
  283.  
  284. extern Int2             NI_DestroyMsgPreResp PROTO((NIPreRespPtr));
  285.  
  286. extern NIAcctPtr        NI_MakeMsgAcct PROTO((void));
  287.  
  288. extern Int2             NI_DestroyMsgAcct PROTO((NIAcctPtr));
  289.  
  290. extern NISvcPtr         NI_MakeService PROTO((void));
  291.  
  292. extern Int2             NI_DestroyService PROTO((NISvcPtr));
  293.  
  294. extern NIResPtr         NI_MakeResource PROTO((void));
  295.  
  296. extern Int2             NI_DestroyResource PROTO((NIResPtr));
  297.  
  298. extern NIRegionPtr      NI_MakeRegion PROTO((void));
  299.  
  300. extern Int2             NI_DestroyRegion PROTO((NIRegionPtr));
  301.  
  302. extern ReqPtr           NI_MakeRequest PROTO((void));
  303.  
  304. extern Int2             NI_DestroyRequest PROTO((ReqPtr));
  305.  
  306. extern NICatalogPtr     NI_MakeMsgCatalog PROTO((void));
  307.  
  308. extern Int2             NI_DestroyMsgCatalog PROTO((NICatalogPtr));
  309.  
  310. extern NI_UidPtr        NI_MakeUid PROTO((void));
  311.  
  312. extern Int2             NI_DestroyUid PROTO((NI_UidPtr));
  313.  
  314. extern NIPubKeyPtr      NI_MakePubKey PROTO((void));
  315.  
  316. extern Int2             NI_DestroyPubKey PROTO((NIPubKeyPtr));
  317.  
  318. extern int              NI_ReadPubKey PROTO((AsnIoPtr extaip, AsnTypePtr extatp, NIPubKeyPtr dip));
  319. extern void             NI_WritePubKey PROTO((AsnIoPtr extaip, AsnTypePtr extatp, NIPubKeyPtr dip));
  320.  
  321. extern NIDispInfoPtr    NI_MakeDispInfo PROTO((void));
  322.  
  323. extern Int2             NI_DestroyDispInfo PROTO((NIDispInfoPtr));
  324.  
  325. extern int              NI_ReadDispInfo PROTO((AsnIoPtr extaip, AsnTypePtr extatp, NIDispInfoPtr dip));
  326. extern void             NI_WriteDispInfo PROTO((AsnIoPtr extaip, AsnTypePtr extatp, NIDispInfoPtr dip));
  327.  
  328. extern NIToolsetPtr     NI_MakeToolset PROTO((void));
  329.  
  330. extern Int2             NI_DestroyToolset PROTO((NIToolsetPtr tsp));
  331.  
  332. extern NIToolsetPtr     NI_GetCatToolset PROTO((NIToolsetPtr tsp));
  333.  
  334.  
  335. #endif
  336.